package com.aegean.MonitorExamSYS.center.action;

import java.io.InputStream;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExaxSYS.model.CenterValue;
import com.aegean.MonitorExaxSYS.model.ExamineeValue;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ShowCenterImage")
@Scope("prototype")
public class ShowCenterImage extends ActionSupport{
	private CenterValue center;
	InputStream user_Photo;
	String photoName;
	String photoType;

	public InputStream getUser_Photo() {
		return user_Photo;
	}

	public void setUser_Photo(InputStream user_Photo) {
		this.user_Photo = user_Photo;
	}

	public String getPhotoName() {
		return photoName;
	}

	public void setPhotoName(String photoName) {
		this.photoName = photoName;
	}

	public String getPhotoType() {
		return photoType;
	}

	public void setPhotoType(String photoType) {
		this.photoType = photoType;
	}

	public InputStream getDownload() {
		try {
			HttpSession session = (HttpSession) ServletActionContext
					.getRequest().getSession();
			center = (CenterValue) session.getAttribute("ServiceLogin");
			user_Photo =center.getUser_Photo().getPhoto()
					.getBinaryStream();
			photoName = center.getUser_Photo().getPhoto_Name();
			photoType = center.getUser_Photo().getPhoto_Type();
			return user_Photo;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
}
